package com.ruoyi.volunteermajor.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.volunteermajor.domain.ExamVolunteerMajor;
import com.ruoyi.volunteermajor.service.IExamVolunteerMajorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "基础管理-志愿专业")
@RestController
@RequestMapping("/volunteermajor")
public class ExamVolunteerMajorController {

    @Autowired
    private IExamVolunteerMajorService volunteerMajorService;

    /**
     * 查询所有专业列表
     */
                @ApiOperation("志愿专业管理 - 分页查询列表")
    @GetMapping("/list")
    public AjaxResult list() {
        List<ExamVolunteerMajor> list = volunteerMajorService.selectVolunteerMajorListByCollegeId(null);
        return AjaxResult.success(list);
    }

    /**
     * 根据学院ID查询专业列表
     */
                @ApiOperation("志愿专业管理 - 根据学院ID查询列表")
    @GetMapping("/listByCollegeId")
    public AjaxResult listByCollegeId(@RequestParam Long collegeId) {
        List<ExamVolunteerMajor> list = volunteerMajorService.selectVolunteerMajorListByCollegeId(collegeId);
        return AjaxResult.success(list);
    }

    /**
     * 根据ID获取专业详情
     */
                @ApiOperation("志愿专业管理 - 根据ID获取详细信息")
    @GetMapping("/info")
    public AjaxResult getInfo(@RequestParam Long id) {
        return AjaxResult.success(volunteerMajorService.selectVolunteerMajorById(id));
    }

    /**
     * 新增专业
     */
                @ApiOperation("志愿专业管理 - 新增数据")
    @PostMapping
    public AjaxResult add(@RequestBody ExamVolunteerMajor volunteerMajor) {
        return AjaxResult.success(volunteerMajorService.insertVolunteerMajor(volunteerMajor));
    }

    /**
     * 修改专业
     */
                @ApiOperation("志愿专业管理 - 修改数据")
    @PutMapping
    public AjaxResult edit(@RequestBody ExamVolunteerMajor volunteerMajor) {
        return AjaxResult.success(volunteerMajorService.updateVolunteerMajor(volunteerMajor));
    }

    /**
     * 删除专业
     */
                @ApiOperation("志愿专业管理 - 删除数据")
    @DeleteMapping
    public AjaxResult remove(@RequestParam Long id) {
        return AjaxResult.success(volunteerMajorService.deleteVolunteerMajorById(id));
    }
}
